******************************************************************************************
/*	December 28, 2020
	Replication run using Stata 16
	
	Gonzales, León-Ciliotta and Martínez, "How Effective Are Monetary Incentives to Vote? Evidence from a Nationwide Policy"
	This file replicates Figures 4 and E1
*/
******************************************************************************************

clear

*global dir "" // If running this do-file on its own, make sure to first run program "Stata_setup" and then program "Data_google" to create the necessary CLEAN data files and use global dir to specify the correct path”. 
global P_INTERMEDIATE "Replication_files/Data/INTERMEDIATE"
global P_CLEAN "Replication_files/Data/CLEAN"
global P_RESULTS "Replication_files/Results"

use "$P_CLEAN/google_trends.dta", clear

******************************************************************************************
*Figure 4: The Reform to the Abstention Fine and Information Acquisition
******************************************************************************************
preserve
reghdfe ln_google multa_2006-multa_2016, absorb(search_term mes) cluster(search mes)
parmest,saving("$P_INTERMEDIATE\trends_event_yr", replace)
restore

preserve
use "$P_INTERMEDIATE\trends_event_yr", clear
drop if parm=="_cons"
gen year=substr(parm,7,4)
destring year,replace
set obs 13
mvencode estimate min max,mv(0)
replace year=2005 if missing(year)
sort year
gen elections=(year==2006)|(year==2010)|(year==2011)|(year==2014)|(year==2016)

twoway (rcap min95 max95 year, lcolor(gs7)) (scatter estimate year if elections==0,msymbol(circle) mcolor(brown)) (scatter estimate year if elections==1, msymbol(square)), ///
ylabel(0(1)5, angle(horizontal)) yscale(range(0 5.5)) ytitle("ln Google trends index (DD estimate)") xscale(range(2005 2017)) xline(2006 2010, lpattern(dash)) xlabel(2005(1)2016, angle(forty_five)) ///
text(5.2 2007 "Initial" "assignment" 5.2 2011 "Adjusted" "assignment",size(small) justification(left)) ///
legend(order(2 "Non-election year" 3 "Election year" 1 "95% C.I.") r(1)) ///
 graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) name(trends_event_yr,replace)
graph export "$P_RESULTS\Figures\Figure4.pdf", as(pdf) replace
restore
erase "$P_INTERMEDIATE\trends_event_yr.dta"

******************************************************************************************
*Figure E1: The Reform to the Abstention Fine and Information Acquisition (monthly level)
******************************************************************************************
preserve
reghdfe ln_google ib541.mes##i.multa, absorb(search_term) cluster(search_term mes)
parmest,saving("$P_INTERMEDIATE\trends_event", replace)
restore

preserve
use "$P_INTERMEDIATE\trends_event", clear
gen temp=substr(parm,9,1)
drop if temp==""|temp=="#"
gen month=substr(parm,1,3)
drop if month =="_co"
destring month,replace
format month %tm
set obs 144
mvencode estimate min max,mv(0)
replace month=541 if missing(month)
sort month
gen elections=(month==555)|(month==557)|(month==562)|(month==609)|(month==615)|(month==617)|(month==657)|(month==675)|(month==677)
twoway (scatter estimate month if elections==0, msize(vsmall)) (scatter estimate month if elections==1, msize(small)) (rcap min95 max95 month, lwidth(vthin)), ///
ylabel(, angle(horizontal)) ytitle(ln Google trends index (DD estimate)) xscale(range(540 683)) xline(561 609, lpattern(dash)) xlabel(540(12)683, angle(forty_five)) xtitle(Month) ///
text(7 571 "Initial" "assignment" 7 619 "Adjusted" "assignment",size(small) justification(left)) ///
legend(order(1 "Non-election" 2 "Election" 3 "95% confidence interval") r(1)) ///
scheme(sj) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) name(event_google,replace)
graph export "$P_RESULTS\Figures\FigureE1.pdf", as(pdf) replace
restore
erase "$P_INTERMEDIATE\trends_event.dta"
